package es

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"srv/app_config"
)

var (
	Es  *elasticsearch.Client
	err error
)

func Init() {
	ec := app_config.AppConf.EsConfig
	addr := fmt.Sprintf("http://%s:%d", ec.Host, ec.Port)
	cfg := elasticsearch.Config{
		Addresses: []string{addr},
		// ...
	}
	Es, err = elasticsearch.NewClient(cfg)
	if err != nil {
		panic(err)
	}
	fmt.Println("es 连接成功:", addr)
}
